package com.zoro.barn.business.service.system.business.role.dao;

import com.zoro.barn.commons.db.annotations.MybatisMapper;
import com.zoro.barn.commons.db.annotations.NeedPage;
import com.zoro.barn.business.service.system.business.role.entity.BarnRole;
import com.zoro.barn.business.service.system.business.role.entity.BarnRoleMenuDto;
import com.zoro.barn.business.service.system.business.role.entity.BarnRoleUserDto;

import java.util.List;
import java.util.Set;

/**
 * @author zhaoxingwu
 */
@MybatisMapper
public interface BarnRoleMapper {

    /**
     * 插入新数据
     *
     * @param data 数据
     */
    void insert(BarnRole data);

    /**
     * 主键更新
     *
     * @param data data
     */
    void update(BarnRole data);


    /**
     * delete by pid
     *
     * @param pid pid
     */
    void deleteById(String pid);

    /**
     * 主键查询
     *
     * @param pid 主键
     * @return 查询结果
     */
    BarnRole getById(String pid);

    /**
     * 条件查询
     *
     * @param role 查询条件
     * @return 查询结果集
     */
    @NeedPage
    List<BarnRole> query(BarnRole role);

    /**
     * 查询用户的所有可用角色
     *
     * @param userId user id
     * @return roles
     */
    List<BarnRole> getByUserId(String userId);

    /**
     * 查询某个角色的用户情况
     *
     * @param dto {@link BarnRoleUserDto}
     * @return user
     */
    @NeedPage
    List<BarnRoleUserDto> getUsers(BarnRoleUserDto dto);

    /**
     * find menus that one role have
     *
     * @param dto dto
     * @return result
     */
    @NeedPage
    List<BarnRoleMenuDto> getMenus(BarnRoleMenuDto dto);

    /**
     * 查询 team 的默认角色
     * @param teamId team id
     * @return result
     */
    List<BarnRole> getByTeamId(String teamId);
    List<BarnRole> getByTeamIds(Set<String> teamIds);

}
